package com.atguigu.gulimall.product.feign;

import com.atguigu.common.to.SkuReductionTo;
import com.atguigu.common.to.SpuBoundsTo;
import com.atguigu.common.utils.R;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 * @Author:Panghl
 * @Description:
 * @Date: Created in 20:28 2022/6/13
 * @Modified By:
 */
@FeignClient("gulimall-coupon")
public interface CouponFeignService {

    /**
     * 1. spuBoundsService.saveSpuBounds(spuBounds);
     *  1) @RequestBody 将这个对象转为json
     *  2) 找到gulimall-coupon服务，给/coupon/spubounds/save发送请求。将上一步转的json放在请求体的位置发送请求
     *  3) 对方服务收到请求，请求体里有json数据
     *    @RequestBody SpuBoundsEntity spuBounds ： 将请求体的json转为SpuBoundsEntity；
     *
     *  只要json数据模型是兼容的，双方服务无需使用同一个to
     * @param boundsTo
     */
    @PostMapping("/coupon/spubounds/save")
    R saveSpuBounds(@RequestBody SpuBoundsTo boundsTo);

    @PostMapping("/coupon/skufullreduction/saveInfo")
    R saveSkuReduction(@RequestBody SkuReductionTo skuReductionTo);
}
